<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author Cheng
-->
<template>
  <div>
    <BasicTable @register="registerTable">
      <template #tableTitle>
        <Icon :icon="getTitle.icon" class="m-1 pr-1" />
        <span> {{ getTitle.value }} </span>
      </template>
      <template #regionCountColumn="{ record }">
        <a @click="handleCountRegion(record)" :title="record.enterpriseId">
          {{ record.enterpriseId }}
        </a>
      </template>
    </BasicTable>
  </div>
</template>
<script lang="ts" setup name="ViewsUnitmanagecountRegionList">
  import { ref,unref } from 'vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { router } from '/@/router';
  import { Icon } from '/@/components/Icon';
  import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
  import {countRegion } from '/@/api/unitmanage/countRegion';
  import { useDrawer } from '/@/components/Drawer';
  import { FormProps } from '/@/components/Form';
  // import InputForm from './form.vue';

  // const record = ref<countRegion>({} as countRegion);
  const { t } = useI18n('unitmanage.countRegion');
  const { showMessage } = useMessage();
  const { meta } = unref(router.currentRoute);

  const getTitle = {
    icon: meta.icon || 'i-ant-design:book-outlined',
    value: meta.title || t('建筑信息表管理'),
  };

  const searchForm: FormProps = {
    baseColProps: { md: 8, lg: 6 },
    labelWidth: 90,
    schemas: [
      {
        label: t('主体名称'),
        field: 'name',
        component: 'Input',
      },
    ],
  };

  const tableColumns: BasicColumn[] = [
    {
      title: t('企业名称'),
      dataIndex: 'enterprisename',
      key: 'a.enterprise_name',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('设备数量'),
      dataIndex: 'regioncount',
      key: 'a.region_count',
      sorter: true,
      width: 130,
      align: 'left',
      // slot: 'regionCountColumn',
    },
  
  ];

  const actionColumn: BasicColumn = {
    width: 160,
  };

  const [registerTable, { reload }] = useTable({
    api: countRegion,
    beforeFetch: (params) => {
      return params;
    },
    columns: tableColumns,
    formConfig: searchForm,
    showTableSetting: true,
    useSearchForm: true,
    canResize: true,
  });
  function handleCountRegion(record: Recordable) {
    router.push({
      path: '/sys/unitRegion/list',
      query: {
        enterpriseId: record.enterpriseId,
      },
    });
  }
</script>
